//----------------------Header-------------------
//files to download
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile("scoreboard/scoreboard.lua")
//loading
include( 'shared.lua' )
include('scoreboard/scoreboard.lua')


//----------------SpawnMenu-------------------------------

AddCSLuaFile( 'Spawn_menus/cl_Spawnderma.lua')
include( 'Spawn_menus/cl_Spawnderma.lua')

//--------------------------------------------------


function GM:PlayerSpawn( ply )  //What happens everytime the player spawns
 
    self.BaseClass:PlayerSpawn( ply )   
 
    ply:SetGravity( 0.75 )  
    ply:SetMaxHealth( 100, true )  
 
    ply:SetWalkSpeed( 325 )  
	ply:SetRunSpeed( 325 ) 
 
end
function GM:PlayerInitialSpawn( ply )  // When spawning after joining the sever
ply:Spectate(5)
RunConsoleCommand( "sb_start" )	 //Run the console command defined in cl_init.lua. 
end //close the function
function GM:PlayerLoadout( ply ) // What should the player recieve when joining a team?
 
	if ply:Team() == 1 then //If he is team 1, then give him the following items
 
		ply:Give( "weapon_physcannon" ) // A Gravity gun
		ply:Give( "weapon_physgun" ) // A Physics gun
		ply:Give( "gmod_tool" ) // and don't forget the tool gun!
 	elseif ply:Team() == 2 then // So if he isn't team 1, he could be team 2?
 
		ply:Give( "weapon_physcannon" ) //Assuming he is, then give him Gravity gun
		ply:Give( "weapon_physgun" ) // Physics gun
		ply:Give( "gmod_tool" ) // and the gmod tool
 
	end //right here.
end //End the function
function sb_team1( ply ) //Blue Team
	ply:UnSpectate() //Since he was set to spectate until he presses the 'hell yeah' button, we now unspecatate him
	ply:SetTeam( 1 ) //We set his team to one, a.k.a 'guest'
	ply:Spawn() //Spawn the player
	ply:PrintMessage( HUD_PRINTTALK, "[CTFbeta]Welcome to the Blue Team, " .. ply:Nick() ) //Gives the message [SimpleBuild]Welcome to the server, (playername here)"  in the talk area.
 
end //End the function.
function sb_team2( ply ) // Function sb_team2. Called at the beginning
	// Why no unspectate? Look carefully at the GM:PlayerSpawn; We only call to spectate after we see if he's an admin. Assuming he's always ready to build, I chose to skip it.	
	ply:UnSpectate()
	ply:SetTeam( 2 ) //Set his team to team 2.
	ply:Spawn() // Spawn him
	ply:PrintMessage( HUD_PRINTTALK, "[CTFbeta]Welcome to the Red Team, " .. ply:Nick() ) //Again, a message in the talk area. 
	//This time saying "[SimpleBuild] I recognize you as an admin (playername here)" 
 
end //End this function
concommand.Add( "sb_team1", sb_team1 ) //Now, we make sure that when we enter sb_team1 into console that it calls the function. This is KEY. Otherwise players won't be able to play.
concommand.Add( "sb_team2", sb_team2 ) //Now, we make sure that when we enter sb_team1 into console that it calls the function. This is KEY. Otherwise players won't be able to play.
function joining( ply ) // The function that's called when the player is not admin or a special character, at the top.
 
	ply:Spectate( 5 )
	ply:SetTeam( 3 )
 
end //End the function
function GM:ShowHelp( ply )
    RunConsoleCommand( "sb_start" )
end
function GM:PlayerSetModel( ply )
	if ply:Team() == 1 then 
		ply:SetModel( "models/player/riot.mdl" )
	elseif ply:Team()== 2 then 
		ply:SetModel("models/player/police.mdl")
	else 
		ply:SetModel( "models/player/alyx.mdl" )
	end
end
